﻿<!DOCTYPE HTML>
<html lang="zh">
<head>
<title>获取窗口类名 - 语法 &amp; 使用 | AutoHotkey v2</title>
<meta name="description" content="The 获取窗口类名 function retrieves the specified window's class name." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
<script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script>
</head>
<body>

<h1>获取窗口类名</h1>

<p>获取指定窗口的类名.</p>

<pre class="Syntax">Class := <span class="func">获取窗口类名</span>(<span class="optional">WinTitle, WinText, ExcludeTitle, ExcludeText</span>)</pre>
<h2 id="Parameters">参数</h2>
<dl>

  <dt>WinTitle</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a>, <a href="../Concepts.htm#numbers">整数</a>或<a href="../Objects.htm">对象</a></p>
    <p>窗口标题或标识目标窗口的其他条件. 请参阅 <a href="../misc/WinTitle.htm">WinTitle</a>.</p>
  </dd>

  <dt>WinText</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
    <p>如果使用此参数, 那么它必须是目标窗口中单个文本元素的子字符串(和内置的 Window Spy 工具显示的一样). 如果 <a href="DetectHiddenText.htm">检测隐藏文本</a> 设置为 ON 时, 那么会检测隐藏文本元素.</p>
  </dd>

  <dt>ExcludeTitle</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
    <p>排除标题中含有此参数值的窗口.</p>
  </dd>

  <dt>ExcludeText</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
    <p>排除文本中含有此参数值的窗口.</p>
  </dd>

</dl>

<h2 id="Return_Value">返回值</h2>
<p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
<p>函数返回指定窗口的<a href="../misc/WinTitle.htm#ahk_class">类名</a>.</p>

<h2 id="Error_Handling">错误处理</h2>
<p>如果找不到窗口或在检索窗口类名时出错, 则抛出异常.</p>

<h2 id="Remarks">备注</h2>
<p>仅获取类名(返回值中不包含前缀 &quot;ahk_class&quot;).</p>
<p>窗口标题和文本是区分大小写的. 只有在打开 <a href="DetectHiddenWindows.htm">检测隐藏窗口</a> 设置时, 才会检测隐藏窗口.</p>

<h2 id="Related">相关</h2>
<p><a href="WinGetTitle.htm">获取窗口标题</a>, <a href="Win.htm">Win 函数</a></p>
<h2 id="Examples">示例</h2>
<div class="ex" id="ExBasic">
<p><a href="#ExBasic">#1</a></p>
<pre>信息框 "The active window's class is " 获取窗口类名("A")</pre>
</div>

</body>
</html>